home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug233 / push.c < prev    next >
Text File  |  1987-06-30  |  896b  |  29 lines

  1. /* push.c -- saves current working directory */
  2.  
  3. #include <string.h>
  4. #include <direct.h>
  5. #include <stdio.h>
  6.  
  7. main()
  8. {
  9.    FILE *fi;
  10.    char curdir[67];
  11.    int i, ch;
  12.  
  13.    /* "cdstack.dat is the name chosen to store the CWD -- you can use any name */
  14.  
  15.    fi = fopen("c:\\cdstack.dat","a"); /* Mine is stored in root directory */
  16.                                       /* but you can use any directory*/
  17.  
  18.    getcwd(curdir,67);   /* get current directory and store in "curdir" */
  19.  
  20.       /* write current directory to file */
  21.    for ( i = 0; (i <= strlen(curdir)) && ((ch = fputc(curdir[i], fi)) != EOF); i++)
  22.        ;
  23.  
  24.    /*pad file with ASCII null characters '\0' to total 67 */
  25.    for (i = (strlen(curdir) + 1); (i < 67) && ((ch = fputc('\0', fi)) != EOF); i++)
  26.        ;
  27.     fclose (fi);
  28.  }
  29.